package com.maimao.core.model.resp;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.github.pagehelper.PageInfo;

import java.io.Serializable;
import java.util.List;

/**
 * @author MaoLin Wang
 * @date 2020/11/27 10:13 下午
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PageResult<T> implements Serializable {
    private static final long serialVersionUID = 7252085778810679755L;

    private Integer page;
    private Long total;
    private Integer pageSize;

    private List<T> rows;

    public PageResult(List<T> rows) {
        PageInfo<T>pageInfo=new PageInfo<>(rows);
        this.page=pageInfo.getPageNum();
        this.total=pageInfo.getTotal();
        this.pageSize=pageInfo.getPageSize();
        this.rows = rows;
    }

    public PageResult(List<T> rows,Long total) {
        this.total= total;
        this.rows = rows;
    }


    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }
}
